package cn.com.captureNetPacket.model;


import java.time.LocalDateTime;
import java.util.Map;

import cn.com.captureNetPacket.util.Tools;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

@Data
@Slf4j
public class SignallingInfoDto {
		// sip的callid
		private String callId;
		// VOICE的 callid
		private String callUUID;
		private String fromUser;
		private String toUser;
		private String caller;
		private String called;
		private String deviceNumber;
		private String agentID;
		private String beginTime;
		private String ringTime;
		private String establishTime;
		private String endTime;
		private Map<String,String> appData;
		// 用户客户端挂机
		private String endCase;
		private String clientIP;
		private String clientMAC;
		private String serverIP;
		//呼叫方向，0:呼出,1:呼入
		private String direction="out";
		
		// 设置关联录音的路径
		private String recordPath;
		
		public String toStringPart() {
			return "SignallingInfo [callId=" + callId + ", from=" + fromUser + ", to=" + toUser + ", beginTime=" + beginTime
					+ ", direction=" + direction+ "]";
		}
		
		public SignallingInfo toSignallingInfo() {
			SignallingInfo signallingInfo=new SignallingInfo();
			signallingInfo.setCallId(callId);
			if(callUUID!=null && callUUID.trim().length()>0)
			signallingInfo.setCallUUID(callUUID);
			if(fromUser!=null && fromUser.trim().length()>0)
			signallingInfo.setFromUser(fromUser);
			if(toUser!=null && toUser.trim().length()>0)
			signallingInfo.setToUser(toUser);
			if(caller!=null && caller.trim().length()>0)
			signallingInfo.setCaller(caller);
			if(called!=null && called.trim().length()>0)
			signallingInfo.setCalled(called);
			if(deviceNumber!=null && deviceNumber.trim().length()>0)
			signallingInfo.setDeviceNumber(deviceNumber);
			if(agentID!=null && agentID.trim().length()>0)
			signallingInfo.setAgentID(agentID);
			if(beginTime!=null && beginTime.trim().length()>0)
			signallingInfo.setBeginTime(LocalDateTime.parse(beginTime, Tools.dfFull));
			if(ringTime!=null && ringTime.trim().length()>0)
			signallingInfo.setRingTime(LocalDateTime.parse(ringTime, Tools.dfFull));
			if(establishTime!=null && establishTime.trim().length()>0)
			signallingInfo.setEstablishTime(LocalDateTime.parse(establishTime, Tools.dfFull));
			if(endTime!=null && endTime.trim().length()>0)
			signallingInfo.setEndTime(LocalDateTime.parse(endTime, Tools.dfFull));
			if(appData!=null && appData.size()>0)
			signallingInfo.setAppData(appData);
			if(endCase!=null && endCase.trim().length()>0)
			signallingInfo.setEndCase(endCase);
			if(clientIP!=null && clientIP.trim().length()>0)
			signallingInfo.setClientIP(clientIP);
			if(serverIP!=null && serverIP.trim().length()>0)
			signallingInfo.setServerIP(serverIP);
			if(clientMAC!=null && clientMAC.trim().length()>0)
			signallingInfo.setClientMAC(clientMAC);
			if(direction!=null && direction.trim().length()>0)
			signallingInfo.setDirection(direction);
//			 转换时不能带recordPath 以后观察下
			if(recordPath!=null && recordPath.trim().length()>0)
				signallingInfo.setRecordPath(recordPath);
			return signallingInfo;
		}
			
}
